# Maintainer: Bartlomiej Piotrowski <nospam@bpiotrowski.pl>

pkgname=pkgconf
pkgver=1.7.3
pkgrel=2
pkgdesc='pkg-config compatible utility which does not depend on glib'
url='https://github.com/pkgconf/pkgconf'
arch=('i686' 'x86_64')
license=('ISC')
groups=('base-devel')
makedepends=('meson'
             'ninja')
conflicts=('pkg-config')
provides=('pkg-config')
replaces=('pkg-config')
source=(https://distfiles.dereferenced.org/pkgconf/$pkgname-$pkgver.tar.xz
        001-no-cygpath-conv.patch
        002-meson-write-pc-file.patch)
sha256sums=('b846aea51cf696c3392a0ae58bef93e2e72f8e7073ca6ad1ed8b01c85871f9c0'
            '3bbff179662d718c703c11b0ec34c118c73dc39fab05a90e7a55fccf15c2eb93'
            '9af1f0600ca15e5f285ba54f4cb334f5d7e00f1bc21b6f571d71acd747f303b6')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -i ${srcdir}/001-no-cygpath-conv.patch
  patch -p1 -i ${srcdir}/002-meson-write-pc-file.patch
}

build() {
  mkdir "${srcdir}"/build && cd "${srcdir}"/build

  meson \
    --buildtype=plain \
     --prefix=/usr \
     -Dtests=false \
    "../${pkgname}-${pkgver}"

  meson compile
}

package() {
  cd "${srcdir}"/build

  DESTDIR="$pkgdir" meson install

  cp "$pkgdir"/usr/bin/pkgconf "$pkgdir/usr/bin/${MSYSTEM_CHOST}-pkg-config"
  cp "$pkgdir"/usr/bin/pkgconf "$pkgdir"/usr/bin/pkg-config
}
